<?php

namespace app\admin\middleware;


use dengje\jwt\facade\JWTAuth;
use app\admin\service\auth\AdminService;

class AdminMiddleware
{
    public function handle($request, \Closure $next)
    {
        
        try {
            $payload = JWTAuth::auth();
            $request->admin_id = $payload['admin_id'];
            AdminService::checkApiAuth();
            return $next($request);
        } catch (\Exception $e) {
         
            return error($e->getMessage(),1,[],$e->getCode());
        }

    }
}